﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace WCSY.BLL
{
    public class fg_approveObjDetAppManager
    {
        private readonly WCSY.DAL.fg_approveObjDetAppService dal=new WCSY.DAL.fg_approveObjDetAppService();
        public fg_approveObjDetAppManager()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string id,int lineid)
		{
			return dal.Exists(id,lineid);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public string Add(WCSY.MODEL.fg_approveObjDetApp model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(WCSY.MODEL.fg_approveObjDetApp model)
		{
			return dal.Update(model);
		}
          /// <summary>
        /// 更改单据审核步骤标志
        /// </summary>
        /// <param name="checkinfo">审批意见</param>
        /// <param name="checkFlag">审批标志</param>
        /// <param name="billno">单据代码</param>
        /// <param name="approvpsn">审批岗位</param>
        /// <returns></returns>
        public string updApprovState(string checkinfo, int checkFlag, string billno, string approvpsn) {
            return dal.updApprovState(checkinfo, checkFlag, billno, approvpsn);
        }
         /// <summary>
        /// 驳回功能，删除后面所有审批步骤
        /// </summary>
        /// <param name="checkinfo"></param>
        /// <param name="checkFlag"></param>
        /// <param name="billno">单据编码</param>
        /// <param name="approvpsn">审批岗位</param>
        /// <returns></returns>
        public string delApprovState(string checkinfo, int checkFlag, string billno, string approvpsn)
        {
            return dal.delApprovState(checkinfo, checkFlag, billno, approvpsn);
        }
         /// <summary>
        /// 删除审批流步骤明细表（重新送审与取消审批使用）
        /// </summary>
        /// <param name="billno">单据号</param>
        /// <returns></returns>
        public string delApprovobjdetByBillno(string billno)
        {
            return dal.delApprovobjdetByBillno(billno);
        }
         /// <summary>
        /// 获取登录岗位未审批单据（待办事项用）
        /// </summary>
        /// <param name="approvpsn"></param>
        /// <returns></returns>
        public DataTable getApprovPsnObj(string approvpsn, string sendpsn)
        {
            return dal.getApprovPsnObj(approvpsn,sendpsn);
        }
          /// <summary>
        /// 根据条件查询审批步骤明细表数据
        /// </summary>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public DataTable getApprovobjDet(string where)
        {
            return dal.getApprovobjDet(where);
        }
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string id,int lineid)
		{
			
			return dal.Delete(id,lineid);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WCSY.MODEL.fg_approveObjDetApp GetModel(string id,int lineid)
		{
			
			return dal.GetModel(id,lineid);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<WCSY.MODEL.fg_approveObjDetApp> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<WCSY.MODEL.fg_approveObjDetApp> DataTableToList(DataTable dt)
		{
			List<WCSY.MODEL.fg_approveObjDetApp> modelList = new List<WCSY.MODEL.fg_approveObjDetApp>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				WCSY.MODEL.fg_approveObjDetApp model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new WCSY.MODEL.fg_approveObjDetApp();
					if(dt.Rows[n]["id"]!=null && dt.Rows[n]["id"].ToString()!="")
					{
					model.id=dt.Rows[n]["id"].ToString();
					}
					if(dt.Rows[n]["lineid"]!=null && dt.Rows[n]["lineid"].ToString()!="")
					{
						model.lineid=int.Parse(dt.Rows[n]["lineid"].ToString());
					}
					if(dt.Rows[n]["approvPsn"]!=null && dt.Rows[n]["approvPsn"].ToString()!="")
					{
					model.approvPsn=dt.Rows[n]["approvPsn"].ToString();
					}
					if(dt.Rows[n]["flowStepNo"]!=null && dt.Rows[n]["flowStepNo"].ToString()!="")
					{
						model.flowStepNo=int.Parse(dt.Rows[n]["flowStepNo"].ToString());
					}
					if(dt.Rows[n]["checkInfo"]!=null && dt.Rows[n]["checkInfo"].ToString()!="")
					{
					model.checkInfo=dt.Rows[n]["checkInfo"].ToString();
					}
					if(dt.Rows[n]["checkFlg"]!=null && dt.Rows[n]["checkFlg"].ToString()!="")
					{
						model.checkFlg=int.Parse(dt.Rows[n]["checkFlg"].ToString());
					}
					if(dt.Rows[n]["dealdate"]!=null && dt.Rows[n]["dealdate"].ToString()!="")
					{
						model.dealdate=DateTime.Parse(dt.Rows[n]["dealdate"].ToString());
					}
					if(dt.Rows[n]["rejectDate"]!=null && dt.Rows[n]["rejectDate"].ToString()!="")
					{
						model.rejectDate=DateTime.Parse(dt.Rows[n]["rejectDate"].ToString());
					}
					if(dt.Rows[n]["remarks"]!=null && dt.Rows[n]["remarks"].ToString()!="")
					{
					model.remarks=dt.Rows[n]["remarks"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
    }
}
